use std::{any::Any, collections::HashMap, sync::Arc};

use serde::{Deserialize, Serialize};
use valuation_model::{node::Node, schema::Schema};

use crate::step::Step;

pub struct AttrStep {
    id: String,
    values: HashMap<String, serde_json::Value>,
}
impl AttrStep {
    pub fn new(id: String, values: HashMap<String, serde_json::Value>) -> Self {
        AttrStep { id, values }
    }
}
impl Step for AttrStep {
    fn apply(&self, doc: Arc<Node>, schema: Arc<Schema>) -> crate::step::StepResult {
        let point_node = &doc.node_at(&self.id);
        if point_node.is_none() {
            return crate::step::StepResult::fail("节点不存在".to_string());
        }

        Node::set_attrs(&mut doc.as_ref().clone(), &self.id, &self.values);
        todo!()
    }

    fn to_json(&self) -> serde_json::Value {
        todo!()
    }
}
